package com.blackbird.jang.model;

import com.blackbird.jang.MainActivity;
import com.wiyun.engine.nodes.Node;
import com.wiyun.engine.nodes.Sprite;
import com.wiyun.engine.utils.TargetSelector;

/**
 * 变换颜色
 * 
 * @author jang
 * 
 */
public class ColorchangeButton extends ToolButton {

	public ColorchangeButton(Node normalSprite, Node selectedSprite,
			Node disabledSprite, Node focusedSprite, TargetSelector selector) {
		super(normalSprite, selectedSprite, disabledSprite, focusedSprite,
				selector);

		setPosition(380 * MainActivity.SCALE_X, 750 * MainActivity.SCALE_Y);
	}

	public static ColorchangeButton make(int normalResId, int selectedResId,
			int disabledResId, int focusedResId, Node target, String selector) {

		return new ColorchangeButton(
				Sprite.make(normalResId),
				selectedResId != 0 ? ((Node) (Sprite.make(selectedResId)))
						: null,
				disabledResId != 0 ? ((Node) (Sprite.make(disabledResId)))
						: null,
				focusedResId != 0 ? ((Node) (Sprite.make(focusedResId))) : null,
				new TargetSelector(target, selector, null));
	}

	/**
	 * 　变换方块颜色
	 */
	public void onAction() {

		// GameLayer.isColorchanging = !GameLayer.isColorchanging;
		// if (GameLayer.isColorchanging) {
		// sparkle();
		// } else {
		// reset();
		// }
		// if (selectedBlock == null) {
		// return;
		// }
		//
		// for (int i = 0; i < Block.COLOR.length; i++) {
		// if (selectedBlock.getName().equals(Block.COLOR[i])) {
		//
		// int x = selectedBlock.getPositionIntX();
		// int y = selectedBlock.getPositionIntY();
		//
		// int index = (i + 1) % Block.COLOR.length;
		//
		// map.removeBlock(selectedBlock);
		//
		// selectedBlock = Block.make(Block.ICONS[index]);
		// map.setBlock(x, y, selectedBlock);
		// selectedBlock.sparkle();
		// }
		// }

	}

}
